/*
 * Created on 28/02/2004
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package org.potiorb.orb.poa;

import org.potiorb.orb.ORBImpl;
import org.potiorb.orb.Object;
import org.potiorb.orb.giop.GIOPMessageRequest;
import org.potiorb.orb.portable.ObjectId;
import org.potiorb.orb.giop.GIOPMessageReply;
import org.potiorb.orb.portable.ObjectRef;
import org.potiorb.orb.portable.InvokeHandler;

public class POA {
	private POAManager m_poaManager;
	private ORBImpl m_orb;

	public POA(ORBImpl orb){
		m_orb = orb;
		m_poaManager = new POAManager();
	}

	public POAManager the_POAManager(){
		return m_poaManager;
	}
	public Object servant_to_reference(Servant servant)
	{
		return null;
	}
	public ObjectId activate_object(Servant servant)
	{
		return m_poaManager.addServant(servant);
	}
	public GIOPMessageReply Dispatch(GIOPMessageRequest msg){
               ObjectRef _ref = this.m_orb.getMarshaler().getObjectRef(msg);
               InvokeHandler _servant =  (InvokeHandler)m_poaManager.LocateServant(_ref);
               _servant._invoke(msg);

		GIOPMessageReply msgReply = new GIOPMessageReply();
                return msgReply;
	}

	public Object id_to_reference(ObjectId id){
		return id;
	}

}
